fix: missing types with "moduleResolution": "Node16"#11
Open
TxHawks wants to merge 1 commit intokripod:mainfrom
Open
fix: missing types with "moduleResolution": "Node16"#11TxHawks wants to merge 1 commit intokripod:mainfrom
TxHawks wants to merge 1 commit intokripod:mainfrom
Conversation
Since the filename pointed at by `default` and `import` (`empty`) is not identical to the filename of the `d.ts` file (`index`), the top level `types` field is not enough when using `"moduleResolution":"Node16"` and TypeScript `4.7`. To fix this, `types` must be explicitly specified inside the `exports` object in addition to the top level `types` field. See [firebase/firebase-js-sdk#6300](/firebase/firebase-js-sdk/issues/6300) and [microsoft/playwright#14428](/microsoft/playwright/pull/14428)
mihkeleidast
reviewed
Oct 6, 2022
| "default": "./empty.js", | ||
| "import": "./empty.js" | ||
| "import": "./empty.js", | ||
| "types": "./index.d.ts" |
There was a problem hiding this comment.
Per the TS documentation, types should be first in this object? Does not seem to matter in my testing, just pointing out: https://www.typescriptlang.org/docs/handbook/esm-node.html
|
Hi @kripod, any chance of this getting merged and released? We also ran into this need. |
faultyserver
added a commit
to GamesDoneQuick/react-polymorphic-types
that referenced
this pull request
Apr 18, 2023
As seen in kripod#11, the `types` field needs to be exported for modern node resolution methods to work in typescript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the filename pointed at by
defaultandimport(empty) is not identical to the filename of thed.tsfile (index), the top leveltypesfield is not enough when using"moduleResolution": "Node16"and TypeScript4.7.To fix this,
typesmust be explicitly specified inside theexportsobject in addition to the top leveltypesfield.See firebase/firebase-js-sdk#6300 and microsoft/playwright#14428